<!DOCTYPE html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <title></title>
        <meta name="description" content="">
        <meta name="viewport" content="width=device-width, initial-scale=1">
    </head>
    <body>
        <!--[if lt IE 7]>
            <p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
        <![endif]-->

        <!--组件侵入式声明-->
        <tzb-table-1></tzb-table-1>
        <tzb-table-1-page></tzb-table-1-page>

        <tzb-table-2></tzb-table-2>
        <tzb-table-2-page></tzb-table-2-page>

        <script src="//cdn.bootcss.com/socket.io/1.4.8/socket.io.min.js"></script>
        <script src="//cdn.bootcss.com/rxjs/5.0.0-beta.12/Rx.min.js"></script>

        <script src="tzb.table.js"></script>
        <script>
            var socket = io.connect('http://localhost:3000');
            var tableController = function(vm){
                vm.page = {
                    pageUp: function(vm){
                        vm._cleanWatch();
                        socket.emit("news",{
                            page: 1
                        });
                        console.log("上一页");
                    },
                    pageDown: function(vm){
                        vm._cleanWatch();
                        socket.emit("news",{
                            page: 2
                        });
                        console.log("下一页");
                    }
                };
                vm.filter = {
                    add: function(data){
                        return data + "%";
                    }
                };
                vm.header = {
                    classSelector: "$",
                    data: [
                        "<input type='checkbox'>$class1",
                        "开仓时间$class2",
                        "用户ID$class3",
                        "资金账户$class4",
                        "股票代码$class5",
                        "股票数量",
                        "可卖数量",
                        "成本价",
                        "卖出价",
                        "卖出数量",
                        "当前价",
                        "市值",
                        "锁定",
                        "操作"
                    ]
                };
                socket.on('news', function (data) {
                    vm.body = {
                        id: "code",
                        data: data[0].data
                    };
                    vm._pageShow = true;
                });
            };
            new TzbTable(
                {
                    selector: "tzb-table-1",
                    htmlUrl: "/table.html",
                    controller: tableController
                }
            );
            new TzbTable(
                {
                    selector: "tzb-table-2",
                    htmlNodeList: [
                        {
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "<input type='checkbox' id='[[ id ]]'> "
                        },
                        {
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ begintime }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ userid }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ accountid }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ code }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ canceltimeout }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ sendAmount }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ amount }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ status }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ sendAmount }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ price | add }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "{{ priceCurr }}"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "<button>🔒</button>"
                        },{
                            attr: {
                                className: "class-name",
                                dataId: "id"
                            },
                            data: "<button>平仓</button>"
                        }
                    ],
                    controller: function(vm){
                        vm.page = {
                        pageUp: function(vm){
                            vm._cleanWatch();
                            socket.emit("news",{
                                page: 1
                            });
                            console.log("上一页");
                        },
                        pageDown: function(vm){
                            vm._cleanWatch();
                            socket.emit("news",{
                                page: 2
                            });
                            console.log("下一页");
                        }
                    };
                    vm.header = {
                        classSelector: "$",
                        data: [
                            "<input type='checkbox'>$class1",
                            "开仓时间$class2",
                            "用户ID$class3",
                            "资金账户$class4",
                            "股票代码$class5",
                            "股票数量",
                            "可卖数量",
                            "成本价",
                            "卖出价",
                            "卖出数量",
                            "当前价",
                            "市值",
                            "锁定",
                            "操作"
                        ]
                    };
                    socket.on('news', function (data) {
                        vm.body = {
                            id: "code",
                            data: [
                                {
                                    "accountid": "110011",
                                    "algoName": "DIRECT",
                                    "amount": 4100,
                                    "begintime": "2016-09-30 10:47:24",
                                    "brokerid": "001",
                                    "bstype": "S",
                                    "canceltimeout": 60,
                                    "ccy": "CNY",
                                    "code": "600158",
                                    "createtime": "2016-09-30 10:47:24",
                                    "endtime": "2016-09-30 10:47:24",
                                    "finishAmount": 0,
                                    "frozenFinCapital": 0,
                                    "fundFree": 0,
                                    "fundFrozen": 0,
                                    "hedgeflag": "1",
                                    "id": 22226,
                                    "lastupdate": "2016-09-30 10:47:43",
                                    "market": "SH",
                                    "minOrderamount": 25000,
                                    "offsetflag": "C",
                                    "preId": 0,
                                    "priceCurr": 16.01,
                                    "priceHigh": 0,
                                    "priceLower": 0,
                                    "sendAmount": 0,
                                    "server": "algo1",
                                    "signalid": 0,
                                    "status": 9,
                                    "strategyid": 257,
                                    "tradeonlimit": 0,
                                    "userid": "cqtl001",
                                    "price": "10"
                                },
                                {
                                    "accountid": "110011",
                                    "algoName": "DIRECT",
                                    "amount": 5300,
                                    "begintime": "2016-09-30 10:42:36",
                                    "brokerid": "001",
                                    "bstype": "S",
                                    "canceltimeout": 60,
                                    "ccy": "CNY",
                                    "code": "600801",
                                    "createtime": "2016-09-30 10:42:36",
                                    "endtime": "2016-09-30 10:42:36",
                                    "finishAmount": 0,
                                    "frozenFinCapital": 0,
                                    "fundFree": 0,
                                    "fundFrozen": 0,
                                    "hedgeflag": "1",
                                    "id": 21930,
                                    "lastupdate": "2016-09-30 10:44:16",
                                    "market": "SH",
                                    "minOrderamount": 25000,
                                    "offsetflag": "C",
                                    "preId": 0,
                                    "priceCurr": 7.03,
                                    "priceHigh": 0,
                                    "priceLower": 0,
                                    "sendAmount": 0,
                                    "server": "algo1",
                                    "signalid": 0,
                                    "status": 9,
                                    "strategyid": 257,
                                    "tradeonlimit": 0,
                                    "userid": "cqtl001",
                                    "price": "10"
                                },
                                {
                                    "accountid": "110011",
                                    "algoName": "DIRECT",
                                    "amount": 4100,
                                    "begintime": "2016-09-30 10:42:24",
                                    "brokerid": "001",
                                    "bstype": "S",
                                    "canceltimeout": 60,
                                    "ccy": "CNY",
                                    "code": "600158",
                                    "createtime": "2016-09-30 10:42:24",
                                    "endtime": "2016-09-30 10:42:24",
                                    "finishAmount": 0,
                                    "frozenFinCapital": 0,
                                    "fundFree": 0,
                                    "fundFrozen": 0,
                                    "hedgeflag": "1",
                                    "id": 21249,
                                    "lastupdate": "2016-09-30 10:43:56",
                                    "market": "SH",
                                    "minOrderamount": 25000,
                                    "offsetflag": "C",
                                    "preId": 0,
                                    "priceCurr": 16.01,
                                    "priceHigh": 0,
                                    "priceLower": 0,
                                    "sendAmount": 0,
                                    "server": "algo1",
                                    "signalid": 0,
                                    "status": 9,
                                    "strategyid": 257,
                                    "tradeonlimit": 0,
                                    "userid": "cqtl001",
                                    "price": "10"
                                },
                                {
                                    "accountid": "110011",
                                    "algoName": "DIRECT",
                                    "amount": 6500,
                                    "begintime": "2016-09-30 10:33:00",
                                    "brokerid": "001",
                                    "bstype": "S",
                                    "canceltimeout": 60,
                                    "ccy": "CNY",
                                    "code": "300313",
                                    "createtime": "2016-09-30 10:33:00",
                                    "endtime": "2016-09-30 10:33:00",
                                    "finishAmount": 0,
                                    "frozenFinCapital": 0,
                                    "fundFree": 0,
                                    "fundFrozen": 0,
                                    "hedgeflag": "1",
                                    "id": 20880,
                                    "lastupdate": "2016-09-30 10:33:21",
                                    "market": "SZ",
                                    "minOrderamount": 25000,
                                    "offsetflag": "C",
                                    "preId": 0,
                                    "priceCurr": 16.68,
                                    "priceHigh": 0,
                                    "priceLower": 0,
                                    "sendAmount": 0,
                                    "server": "algo1",
                                    "signalid": 0,
                                    "status": 9,
                                    "strategyid": 257,
                                    "tradeonlimit": 0,
                                    "userid": "cqtl001",
                                    "price": "10"
                                }
                            ]
                        };
                        vm._pageShow = false;
                    });
                    }
                }
            );
        </script>
    </body>
</html>
